define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
<<<<<<< HEAD
//	var outterAMD1 = require("../misc/js/wxaction");

	var jpushInstance = require("../jpush");
	require("$UI/system/lib/cordova/cordova");
	require("cordova!jpush-phonegap-plugin");
=======
	var outterAMD1 = require("../misc/js/wxaction");
	var jpushInstance = require("../jpush");
	require("$UI/system/lib/cordova/cordova");
	require("cordova!cn.jpush.phonegap.JPushPlugin");
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
	var InterValObj; //timer变量，控制时间 
    var count = 30; //间隔函数，1秒执行 
    var curCount;//当前剩余秒数  
    //取消弹出框
    var quxiao=function(){
       $('#wxloading').css("display","none");
    }
    //验证码特效
    var SetRemainTime=function SetRemainTime(){
           if (curCount == 0) {         
              window.clearInterval(InterValObj);
              $(".yanzhengbtn").removeAttr("disabled");
              $(".yanzhengbtn").html("重新发送验证码"); 
            }else { 
              curCount--; 
              $(".yanzhengbtn").html(curCount + "秒后可重新发送"); 
            }
    }
	var Model = function(){
		this.callParent();
	};
   //发送短信验证码
	Model.prototype.button4Click = function(event){	      
        curCount = count; 
        var tel = this.comp("tel").val();
        if(tel==""){
            $('.wx_loading_inner').html("手机号不能为空！");
 		    $('#wxloading').css("display","block"); 
 		    setTimeout(quxiao,2000);
            return; 
        }
    	$.ajax({
            type: "GET",
            url: window.yuming+'/app/sendMsg/'+tel,     
            async: false,
            cache: false,
            success: function(datas){
            	$(".yanzhengbtn").attr("disabled", "true"); 
                $(".yanzhengbtn").html(curCount + "秒后可重新发送"); 
                InterValObj =setInterval(SetRemainTime, 1000);
                return;
            },
            error: function(XMLHttpRequest){
                var code=$.parseJSON(XMLHttpRequest.responseText);
<<<<<<< HEAD
                   justep.Util.hint(code.message,{type:'info',delay:3000,position:'top'});
                   /*$('.wx_loading_inner').html(code.message);
        		   $('#wxloading').css("display","block"); 
        		   setTimeout(quxiao,2000);*/
=======
                  
                   $('.wx_loading_inner').html(code.message);
        		   $('#wxloading').css("display","block"); 
        		   setTimeout(quxiao,2000);
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
                 
            }
    	    })
	};
  
    //提交注册数据
	Model.prototype.regBtnClick = function(event){
<<<<<<< HEAD
	   var tong=this;
=======
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
	   var tel = this.comp("tel").val();
	   var duanxin = this.comp("duanxin").val();
	   var pass = this.comp("pass").val();
	   var rpass = this.comp("rpass").val();
       var payType = this.comp('payTypeSelect').val();
       if(tel=="" || duanxin =="" || pass == "" || rpass=="" || payType == undefined){
           $('.wx_loading_inner').html("所有内容为必填项！");
		   $('#wxloading').css("display","block"); 
		   setTimeout(quxiao,2000);
           return; 
       }
       if(payType==4){
    	   var type=1;
       }else if(payType==5){
    	   var type=2;
       }else{
    	   var type=3; 
       }
       if( pass != rpass){
           $('.wx_loading_inner').html("两次验证码不一致！");
		   $('#wxloading').css("display","block"); 
		   setTimeout(quxiao,2000);
           return;
       }
       	$.ajax({
		        type: "POST",
		        url: window.yuming+'/app/checkMsg',     
		        async: false,
		        cache: false,
		        dataType: 'json',
		        data:{username:tel,code:duanxin,pass:pass,type:type,rid:payType},
		        success: function(datas){
<<<<<<< HEAD
	
		                	window.username = tel;
		                    window.pass = pass;	
		                   // justep.Shell.closeAllOpendedPages(); 
		                  //  tong.comp("registerdialog").open();  
		                    tong.close();
		                   //justep.Shell.closeAllOpendedPages();                 
		                  // justep.Shell.showPage("login");
		                 
		                   
=======
		                	window.username = tel;
		                    window.pass = pass;
		                    justep.Shell.showPage("login");
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
		             
		            },
		        error: function(XMLHttpRequest){
		        var code=$.parseJSON(XMLHttpRequest.responseText);
<<<<<<< HEAD
		          justep.Util.hint(code.message,{type:'info',delay:3000,position:'top'});
		            /*console.log(code)
		            alert(code.message)
		           $('.wx_loading_inner').html(code.message);
				   $('#wxloading').css("display","block"); */
				 //  setTimeout(quxiao,2000);
=======
		          
		           $('.wx_loading_inner').html(code.message);
				   $('#wxloading').css("display","block"); 
				   setTimeout(quxiao,2000);
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
		         
		        }
       });
      
	};
  
 
  
  
	return Model;
});